<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创建简单背景视频</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            min-height: 100vh;
        }
        .container {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 30px;
            backdrop-filter: blur(10px);
        }
        h1 {
            text-align: center;
            margin-bottom: 30px;
        }
        .preview {
            width: 100%;
            height: 300px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 10px;
            margin: 20px 0;
            position: relative;
            overflow: hidden;
        }
        .gradient-bg {
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57);
            background-size: 400% 400%;
            animation: gradientMove 8s ease infinite;
        }
        @keyframes gradientMove {
            0%, 100% { background-position: 0% 50%; }
            25% { background-position: 100% 50%; }
            50% { background-position: 100% 100%; }
            75% { background-position: 0% 100%; }
        }
        .controls {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin: 20px 0;
        }
        .control-group {
            background: rgba(255, 255, 255, 0.1);
            padding: 15px;
            border-radius: 10px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input, select {
            width: 100%;
            padding: 8px;
            border: none;
            border-radius: 5px;
            background: rgba(255, 255, 255, 0.2);
            color: white;
        }
        input::placeholder {
            color: rgba(255, 255, 255, 0.7);
        }
        button {
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 25px;
            cursor: pointer;
            font-size: 16px;
            margin: 10px 5px;
            transition: transform 0.3s;
        }
        button:hover {
            transform: translateY(-2px);
        }
        .info {
            background: rgba(255, 255, 255, 0.1);
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
        }
        .download-link {
            display: none;
            background: rgba(46, 213, 115, 0.2);
            padding: 15px;
            border-radius: 10px;
            margin: 20px 0;
            text-align: center;
        }
        .download-link a {
            color: #2ed573;
            text-decoration: none;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎬 创建动态背景视频</h1>
        
        <div class="preview">
            <canvas id="previewCanvas" width="800" height="300"></canvas>
        </div>
        
        <div class="controls">
            <div class="control-group">
                <label>动画类型</label>
                <select id="animationType">
                    <option value="gradient">渐变流动</option>
                    <option value="particles">粒子效果</option>
                    <option value="waves">波浪效果</option>
                    <option value="geometric">几何图形</option>
                </select>
            </div>
            
            <div class="control-group">
                <label>主色调</label>
                <select id="colorScheme">
                    <option value="rainbow">彩虹色</option>
                    <option value="blue">蓝色系</option>
                    <option value="purple">紫色系</option>
                    <option value="green">绿色系</option>
                    <option value="warm">暖色系</option>
                </select>
            </div>
            
            <div class="control-group">
                <label>动画速度</label>
                <input type="range" id="speed" min="1" max="10" value="5">
            </div>
            
            <div class="control-group">
                <label>视频时长 (秒)</label>
                <input type="number" id="duration" min="5" max="30" value="10">
            </div>
        </div>
        
        <div style="text-align: center;">
            <button onclick="updatePreview()">🔄 更新预览</button>
            <button onclick="generateVideo()">🎬 生成视频</button>
        </div>
        
        <div id="downloadLink" class="download-link">
            <p>✅ 视频生成完成！</p>
            <a href="#" download="background.mp4">📥 下载 background.mp4</a>
        </div>
        
        <div class="info">
            <h3>📋 使用说明</h3>
            <ol>
                <li>选择您喜欢的动画类型和颜色方案</li>
                <li>调整动画速度和视频时长</li>
                <li>点击"生成视频"按钮</li>
                <li>下载生成的 background.mp4 文件</li>
                <li>将文件放置到您的网站根目录</li>
            </ol>
            
            <h3>🎯 推荐设置</h3>
            <ul>
                <li><strong>渐变流动 + 彩虹色</strong>：适合现代科技风格</li>
                <li><strong>粒子效果 + 蓝色系</strong>：适合商务专业风格</li>
                <li><strong>波浪效果 + 紫色系</strong>：适合创意艺术风格</li>
                <li><strong>几何图形 + 暖色系</strong>：适合活力动感风格</li>
            </ul>
        </div>
    </div>

    <script>
        const canvas = document.getElementById('previewCanvas');
        const ctx = canvas.getContext('2d');
        let animationId;
        
        const colorSchemes = {
            rainbow: ['#ff6b6b', '#4ecdc4', '#45b7d1', '#96ceb4', '#feca57'],
            blue: ['#3742fa', '#2f3542', '#40739e', '#487eb0', '#0097e6'],
            purple: ['#8c7ae6', '#9c88ff', '#7158e2', '#3d3d3d', '#40407a'],
            green: ['#00d2d3', '#01a3a4', '#2ed573', '#7bed9f', '#5f27cd'],
            warm: ['#ff9ff3', '#f368e0', '#ff3838', '#ff9f43', '#feca57']
        };
        
        function updatePreview() {
            if (animationId) {
                cancelAnimationFrame(animationId);
            }
            
            const type = document.getElementById('animationType').value;
            const scheme = document.getElementById('colorScheme').value;
            const speed = document.getElementById('speed').value / 5;
            
            let time = 0;
            
            function animate() {
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                
                switch(type) {
                    case 'gradient':
                        drawGradient(time, scheme);
                        break;
                    case 'particles':
                        drawParticles(time, scheme);
                        break;
                    case 'waves':
                        drawWaves(time, scheme);
                        break;
                    case 'geometric':
                        drawGeometric(time, scheme);
                        break;
                }
                
                time += speed;
                animationId = requestAnimationFrame(animate);
            }
            
            animate();
        }
        
        function drawGradient(time, scheme) {
            const colors = colorSchemes[scheme];
            const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
            
            for (let i = 0; i < colors.length; i++) {
                const offset = (Math.sin(time * 0.01 + i) + 1) / 2;
                gradient.addColorStop(i / (colors.length - 1), colors[i]);
            }
            
            ctx.fillStyle = gradient;
            ctx.fillRect(0, 0, canvas.width, canvas.height);
        }
        
        function drawParticles(time, scheme) {
            const colors = colorSchemes[scheme];
            ctx.fillStyle = '#000';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            for (let i = 0; i < 50; i++) {
                const x = (Math.sin(time * 0.01 + i) * 200 + canvas.width / 2);
                const y = (Math.cos(time * 0.015 + i) * 100 + canvas.height / 2);
                const size = Math.sin(time * 0.02 + i) * 5 + 5;
                
                ctx.fillStyle = colors[i % colors.length];
                ctx.beginPath();
                ctx.arc(x, y, size, 0, Math.PI * 2);
                ctx.fill();
            }
        }
        
        function drawWaves(time, scheme) {
            const colors = colorSchemes[scheme];
            ctx.fillStyle = colors[0];
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            for (let i = 0; i < colors.length; i++) {
                ctx.fillStyle = colors[i] + '80';
                ctx.beginPath();
                ctx.moveTo(0, canvas.height);
                
                for (let x = 0; x <= canvas.width; x += 10) {
                    const y = Math.sin((x + time * 2) * 0.01 + i) * 50 + canvas.height / 2 + i * 20;
                    ctx.lineTo(x, y);
                }
                
                ctx.lineTo(canvas.width, canvas.height);
                ctx.closePath();
                ctx.fill();
            }
        }
        
        function drawGeometric(time, scheme) {
            const colors = colorSchemes[scheme];
            ctx.fillStyle = '#000';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            for (let i = 0; i < 20; i++) {
                const x = (Math.sin(time * 0.01 + i) * 300 + canvas.width / 2);
                const y = (Math.cos(time * 0.01 + i) * 100 + canvas.height / 2);
                const size = Math.sin(time * 0.02 + i) * 30 + 30;
                const rotation = time * 0.02 + i;
                
                ctx.save();
                ctx.translate(x, y);
                ctx.rotate(rotation);
                ctx.fillStyle = colors[i % colors.length] + '80';
                ctx.fillRect(-size/2, -size/2, size, size);
                ctx.restore();
            }
        }
        
        function generateVideo() {
            alert('🎬 视频生成功能需要服务器端支持。\n\n💡 简单方案：\n1. 使用屏幕录制软件录制预览动画\n2. 保存为 background.mp4\n3. 放置到网站根目录\n\n🔧 高级方案：\n使用 FFmpeg 或其他视频生成工具');
        }
        
        // 初始化预览
        updatePreview();
        
        // 监听控件变化
        document.getElementById('animationType').addEventListener('change', updatePreview);
        document.getElementById('colorScheme').addEventListener('change', updatePreview);
        document.getElementById('speed').addEventListener('input', updatePreview);
    </script>
</body>
</html>